package com.wuxiaofan.product.service;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.wuxiaofan.product.entity.Brand;
import com.wuxiaofan.product.entity.custom.BrandCustom;
import com.wuxiaofan.product.mapper.BrandMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.wuxiaofan.product.client.Idgenerator;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.annotation.Resource;

@Service
public class BrandService {
    @Autowired
    private BrandMapper pmsBrandMapper;
    @Resource
    private Idgenerator idgenerator;
    public Brand findById(String id){
        return pmsBrandMapper.selectById(id);
    }

    public BrandCustom findCountByMap(Map paraMap){
        return pmsBrandMapper.findCountByMap(paraMap);
    }

    public BrandCustom findGroupByMap(Map paraMap){
        return pmsBrandMapper.findGroupByMap(paraMap);
    }

    public List<BrandCustom> findByMap(Map paraMap){
        return pmsBrandMapper.findByMap(paraMap);
    }

    public Page<BrandCustom> findByMap(Map paraMap, Page page){
        return page.setRecords(pmsBrandMapper.findByMap(paraMap,page));
    }


    public void updateMapById(Map paraMap){
        pmsBrandMapper.updateMapById(paraMap);
    }
    public void delById(String id){
        pmsBrandMapper.deleteById(id);
    }

    public void delByIds(List<Long> ids){
        pmsBrandMapper.delByIds(ids);
    }
    public Brand save(Brand pmsBrand){
        pmsBrand.setBrandId(idgenerator.getId());
        pmsBrandMapper.insert(pmsBrand);
        return pmsBrand;
    }

}
